<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html>
<html>

	<head>
		<title>系统设置-权限设置</title>
		<meta charset="utf-8">
		<link rel="stylesheet" type="text/css" href="<%=basePath %>libs/bootstrap-3.3.7-dist/css/bootstrap.min.css">
		<link rel="stylesheet" type="text/css" href="<%=basePath %>css/reset.css">
		<link rel="stylesheet" type="text/css" href="<%=basePath %>css/style.css">
		<link rel="stylesheet" type="text/css" href="<%=basePath %>css/iframe.css">

	</head>

	<body>
		<div id="mainContent">
			<div id="mainContent_content">
				<div class="page_header">
					<a>权限设置</a>
				</div>
				<div class="search">
					<form class="form" method="post" action="<%=basePath%>Jurisdiction/selectByWhere.do">
						<label>权限模块 </label>
						<input type="text" id="rootname" name="rootname" value="${rootPage.rootname}" class="form-control doubleWidth"></input>
						<input type="hidden" name="currentPage" value="1">
						<span class="btn"> 
					 	<input type="submit" value="查询" class="btn btn1"></input>
						<input type="button" value="清空" onclick="clearSearchParam();" class="btn btn2"></input>
					</span>

					</form>
				</div>

				<div class="tableBox box">
					<table class="table table-bordered table_text_center">
						<thead>
							<tr>
								<th>序号</th>
								<th>操作</th>
								<th>权限名称</th>
								<th>权限状态</th>
							</tr>
						</thead>
						<tbody>
							<c:forEach items="${jsm }" var="jsm" varStatus="i">
								<tr>
									<td>${i.index+1 }</td>
									<td>
										<c:if test="${jsm.status=='关闭' }">
											<a class="btn btn-xs btn1" onclick="updateroot('${jsm.jurisdictionid }','启用');">启用</a>
										</c:if>
										<c:if test="${jsm.status=='启用' }">
											<a class="btn btn-xs btn2" onclick="updateroot('${jsm.jurisdictionid }','关闭');">关闭</a>
										</c:if>
									</td>
									<td>${jsm.jurisdictionname }</td>
									<td>${jsm.status }</td>
								</tr>
							</c:forEach>
						</tbody>
					</table>
				</div>
				<jsp:include page="/jsp/basic/page.jsp"></jsp:include>
			</div>
			<jsp:include page="/jsp/basic/prompt.jsp"></jsp:include>

		</div>
		<script src="<%=basePath%>js/jquery-3.2.1.min.js"></script>
		<script src="<%=basePath%>libs/bootstrap-3.3.7-dist/js/bootstrap.js"></script>
		<script src="<%=basePath%>js/public.js"></script>
		<script type="text/javascript">
			//清空搜索条件
			function clearSearchParam() {
				$(".search input:text").val("");
				$(".search select").val("");
			}
			/* 启用关闭权限 */
			function updateroot(id, status) {
				var delFunc = function() {
					$.ajax({
						url: "<%=basePath%>Jurisdiction/updateroot.do",
						type: "post",
						async: false,
						dataType: "json",
						data: 'jurisdictionid=' + id + "&status=" + status,
						success: function(data) {
							if(data.result == "success") {
								Prompt.alert("提示", status + "成功");
								location.href = location.href;
							} else {
								Prompt.alert("提示", status + "失败！");
							}
						},
						error: function() {
							Prompt.alert("提示", "服务器无响应，请刷新页面后重试！");
						}
					});
				}
				Prompt.confirm("提示", "确认要" + status + "吗?", delFunc);
			}
		</script>
	</body>

</html>